package com.genius.smsservice.studentmanage.service.impl;

import com.genius.smsbase.Enum.ResultEnum;
import com.genius.smsbase.Exception.SystemException;
import com.genius.smsbase.Service.impl.GenericManagerImpl;
import com.genius.smsdao.studentmanage.dao.StudentDao;
import com.genius.smsdao.studentmanage.domain.Student;
import com.genius.smsservice.studentmanage.service.StudentManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @ClassName StudentManagerImpl
 * @Description StudentManager实现类
 * @author：Mie
 */
@Component
public class StudentManagerImpl extends GenericManagerImpl<Student,Long> implements StudentManager {

    StudentDao studentDao;

    @Autowired
    public void setStudentDao(StudentDao studentDao){
        this.studentDao = studentDao;
        this.dao = this.studentDao;
    }

    @Override
    public Student findByNumber(String number){
        if(studentDao.findByNumber(number).isPresent()){
            return studentDao.findByNumber(number).get();
        }else{
            throw new SystemException(ResultEnum.UNKNOW_USER_ERROR);
        }
    }

}
